﻿using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Windows;

namespace xCarLinkMP3Organizer
{
    internal class StartEmptyWinamp : WinampCommand
    {
        protected override void InternalExecute(ProcessStartInfo psi, DiscViewModel dvm)
        {
            if (!WinampLib.IsOpened())
            {
                int i = 0;
                Process.Start(new ProcessStartInfo(GetWinampExecutable()));
                while (!WinampLib.IsOpened())
                {
                    Thread.Sleep(100);
                    i++;
                    if (i > 100)
                        return;
                }
            }

            WinampLib.DeleteCurrentPlaylist();
            Process.Start(psi);
        }

        protected override StringBuilder GetArgs(DiscViewModel dvm)        {            return base.GetArgs(dvm).Append(" /add " + dvm.Path);        }
    }
}